package jhlee42;

import java.util.Scanner;

public class J10SungJuk {
	
	// return 을 이용한 메서드
	// 주의 : Scanner 클래스를 이용해서 입력처리하고 close() 하면 다시 Scanner 생성 불가
	
	
	
	
	public static void main(String[] args) {
		String name = null;
		int kor = 0,eng = 0,mat = 0,tot;
		double avg;
		char grd;
	
		name=nameInput(makeScanner());
		kor=korInput(makeScanner());
		eng=engInput(makeScanner());
		mat=matInput(makeScanner());
			
		// 성적 처리
		tot = getTotal(kor,eng,mat);
		avg = getAverage(tot);
		grd = getGrade(avg);
		
		// 결과 출력
		System.out.println(name);
		System.out.println(tot);
		System.out.println(avg);
		System.out.println(grd);
	}
		
	// Scanner 생성
	public static Scanner makeScanner(){
		Scanner sc = new Scanner(System.in);
		return sc;
	}
	
	// Scanner 소멸
	
	public static Scanner closeScanner(Scanner sc){
		sc.close();
		return sc;
	}

	public static String nameInput(Scanner sc){		
		String name;
		makeScanner();
		System.out.println("이름을 입력하세요..");
		name = sc.next(); // 이름 입력받음	
		closeScanner(sc);
		return name;		
	}
	public static int korInput(Scanner sc){
		makeScanner();
		int kor;	
		System.out.println("국어 점수를 입력하세요");
		kor = sc.nextInt(); // 국어 입력받음
		closeScanner(sc);
		return kor;		
	}
	public static int engInput(Scanner sc){
		makeScanner();
		int eng;
		System.out.println("영어 점수를 입력하세요");
		eng= sc.nextInt(); // 영어 입력받음
		closeScanner(sc);
		return eng;		
	}
	public static int matInput(Scanner sc){
		makeScanner();
		int mat;
		System.out.println("수학 점수를 입력하세요");
		mat = sc.nextInt(); // 수학 입력받음		
		closeScanner(sc);
		return mat;
	}

	
	
	
	public static int getTotal(int kor,int eng,int mat){
		return  kor+eng+mat;
	}
	public static double getAverage(int tot){		
		return (double) tot / 3;
	}	
	public static char getGrade(double avg){
		char grd;
		switch ((int)avg/10) {
		case 10:
		case 9:grd = '수'; break;
		case 8:grd = '우'; break;
		case 7:grd = '미'; break;
		case 6:grd = '양'; break;
		default : grd = '가'; 
		
	    }
		return grd;
	}
}
